home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / vdl020d.zip / VMEMNEW.DOC < prev    next >
Text File  |  1993-04-14  |  5KB  |  210 lines

  1. (*
  2.  
  3. ════════════════════════════════════════════════════════════════════════════
  4.  
  5. Visionix Memory Management Unit (VMEM)
  6. Copyright 1991,1992 Visionix
  7. ALL RIGHTS RESERVED
  8.  
  9. ────────────────────────────────────────────────────────────────────────────
  10.  
  11. Revision history in reverse chronological order:
  12.  
  13. Initials  Date      Comment
  14. ────────  ────────  ────────────────────────────────────────────────────────
  15.  
  16.  
  17. jrt       11/21/92  Sync with beta 0.08
  18.  
  19. jrt       08/01/92  First logged revision.
  20.  
  21. ────────────────────────────────────────────────────────────────────────────
  22.  
  23. Known bugs/caveats:
  24.  
  25.  
  26.  
  27. ════════════════════════════════════════════════════════════════════════════
  28.  
  29. *)
  30.  
  31.  
  32.  
  33. Unit VMem;
  34.  
  35.  
  36. Uses
  37.  
  38.   VTypes;
  39.  
  40.  
  41. Const
  42.  
  43.   allocZERO      = $01;
  44.  
  45.  
  46.   Type
  47.  
  48.     THeapHandle = POINTER;
  49.  
  50.     THeapEventProc = Procedure( HeapEvent : POINTER );
  51.  
  52.     THeapMethodProc = Procedure ( HeapDCB : POINTER );
  53.  
  54.     TMemHandle = POINTER;
  55.  
  56.     TMemHeader = RECORD
  57.  
  58.       Locks    : LONGINT;
  59.       Size     : LONGINT;
  60.       Ptr      : Pointer;
  61.  
  62.     END;
  63.  
  64.     PMemHeader = ^TMemHeader;
  65.  
  66.  
  67.   {------------}
  68.   { Heap event }
  69.   {------------}
  70.  
  71.   Type
  72.  
  73.     THeapEvent = RECORD
  74.  
  75.       EventCode   : LONGINT;
  76.  
  77.       Data1       : LONGINT;
  78.       Data2       : LONGINT;
  79.       Data3       : LONGINT;
  80.  
  81.     END;
  82.  
  83.     PHeapEvent = ^THeapEvent;
  84.  
  85.   {---------------------------}
  86.   { Heap Driver control block }
  87.   {---------------------------}
  88.  
  89.   THeapDCB = RECORD
  90.  
  91.     Func           : WORD;
  92.  
  93.     Flags          : WORD;
  94.  
  95.     Name           : ST80;
  96.     HeapDriverProc : THeapDriverProc;
  97.     ID             : POINTER;
  98.     HeapEventPRoc  : THeapEventProc;
  99.     Size           : LONGINT;
  100.  
  101.     HeapHandle     : THeapHandle;
  102.     MemHandle      : TMemHandle;
  103.  
  104.  
  105.     Status         : WORD;
  106.  
  107.   END;
  108.  
  109.   PHeapDCB = THeapDCB;
  110.  
  111.  
  112.   {----------------------}
  113.   { Heap driver instance }
  114.   {----------------------}
  115.  
  116.   PHeapDriverInstance = ^THeapDriverInstance;
  117.  
  118.   THeapDriverInstance = RECORD
  119.  
  120.     Flags          : WORD;
  121.     Name           : ST80;
  122.     HeapDriverProc : THeapDriverProc;
  123.     Data           : POINTER;
  124.  
  125.     Next           : PHeapDriverInstance;
  126.  
  127.   END;
  128.  
  129.  
  130.  
  131.  
  132. Var
  133.  
  134.   HeapDriverInstanceList : PHeapDriverInstance;
  135.  
  136.  
  137. (*
  138.  
  139. Function  VMemHeapDriverNew(      Flags          : WORD;
  140.                                   MethodName     : ST80;
  141.                                   HeapDriverProc : THeapDriverProc;
  142.                                   HeapDriverID   : POINTER          ) : WORD;
  143.  
  144.  
  145.  
  146.  
  147. Function  VMemHeapNew(            Flags          : WORD;
  148.                                   MethodListStr  : ST80;
  149.                                   HeapEventProc  : THeapEventProc;
  150.                                   SizeK          : LONGINT        ):THeapHandle;
  151.  
  152.  
  153. Procedure VMemHeapDispose(        Flags          : WORD;
  154.                                   Handle         : THeapHandle    );
  155.  
  156.  
  157.  
  158.  
  159.  
  160. *)
  161.  
  162.  
  163. Function  VMemAlloc(              HeapHandle     : THeapHandle;
  164.                                   Flags          : WORD;
  165.                                   Size           : LONGINT         ):TMemHandle;
  166.  
  167.   { Allocates a memory handle.  The memory is allocated from the   }
  168.   { heap associated with HeapHandle.  The HeapHandle is obtained   }
  169.   { from a previous call to VMemHeapNew.                           }
  170.   {                                                                }
  171.   { Flags               Allocation control flags                   }
  172.   {                       allocZERO zero out allocated memory.     }
  173.   {                                                                }
  174.   { [RETURNS]           Memory Handle,                             }
  175.   {                       0 if error.                              }
  176.  
  177.  
  178. Function  VMemLock(               MemHandle      : TMemHandle      ):Pointer;
  179.  
  180.   { Locks down the memory associated with a memory handle, and     }
  181.   { returns a pointer to it.                                       }
  182.   {                                                                }
  183.   { MemHandle           Previously allocated memory handle.        }
  184.   {                                                                }
  185.   { [RETURNS]           Pointer to memory,                         }
  186.   {                       NIL if error.                            }
  187.  
  188.  
  189. Procedure VMemUnlock(             MemHandle      : TMemHandle      );
  190.  
  191.   { Unlocks the memory associated with a memory handle, invaliding }
  192.   { any pointer to the memory previously obtained via VMemLock.    }
  193.   {                                                                }
  194.   { MemHandle           Previously allocated memory handle.        }
  195.   {                                                                }
  196.  
  197.  
  198. Procedure VMemFree(               MemHandle      : TMemHandle      );
  199.  
  200.   { VMemFree frees a memory handle and the memory associated with  }
  201.   { it.                                                            }
  202.   {                                                                }
  203.   { MemHandle           Previously allocated memory handle.        }
  204.  
  205.  
  206.  
  207. {---------------------------------------------------------------------------}
  208.  
  209.  
  210.